window.onload = function () {
  init();
}

function init() {
  initEvent();
}

function initEvent() {
  var thumbItems = document.getElementsByClassName('thumb-item') 
  var sliderItems = document.getElementsByClassName('slider-item')

  for(var i = 0; i < thumbItems.length; i++) {
    (function (index) { // 形参
      thumbItems[index].onclick = function () {
        for(var j = 0; j< thumbItems.length; j ++) {
          thumbItems[j].className = "thumb-item";
          sliderItems[j].className = "slider-item";
        }
        this.className += ' cur';
        sliderItems[index].className += ' active'
      }
    })(i); // 实参
  }
}

